We have developed a new method, close in philosophy to the photometric redshift technique, which can be applied to spectral data of very low signal-to-noise ratio. Using it we intend to measure redshifts while minimising the dangers posed by the usual extraction techniques. GRB afterglows have generally very simple optical spectra over which the separate effects of absorption and reddening in the GRB host, the intergalactic medium, and our own Galaxy are superimposed. We model all these effects over a series of template afterglow spectra to produce a set of clean spectra that reproduce what would reach our telescope. We also model carefully the effects of the telescope-spectrograph combination and the properties of noise in the data, which are then applied on the template spectra. The final templates are compared to the two-dimensional spectral data, and the basic parameters (redshift, spectral index, Hydrogen absorption column) are estimated using statistical tools. We show how our method works by applying it to our data of the NIR afterglow of GRB090423. At z ~ 8.2, this was the most distant object ever observed. We use the spectrum taken by our team with the Telescopio Nazionale Galileo to derive the GRB redshift and its intrinsic neutral Hydrogen column density. Our best fit yields z=8.4^+0.05/-0.03 and N(HI)<5x10^20 cm^-2, but with a highly non-Gaussian uncertainty including the redshift range z [6.7, 8.5] at the 2-sigma confidence level. Our method will be useful to maximise the recovered information from low-quality spectra, particularly when the set of possible spectra is limited or easily parameterisable while at the same time ensuring an adequate confidence analysis.